package com.ymatou.iapi.livebuyer.testcase;

import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.livebuyer.parameter.GetGlobalUserSigBean;
import com.ymatou.iapi.livebuyer.service.GetGlobalUserSigCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.database.sqlwapper.LiveRoomWapper;
import com.ymttest.utils.TestDataManager;
/**
*获取云通信用户签名
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetGlobalUserSig{
	private static GetGlobalUserSigBean GetGlobalUserSigBean;
	private static GetGlobalUserSigCall GetGlobalUserSigCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取云通信用户签名");
	}

	@Before
	public void caseUp() {
		GetGlobalUserSigBean=new GetGlobalUserSigBean();
		GetGlobalUserSigCall=new GetGlobalUserSigCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(GetGlobalUserSigCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetGlobalUserSig_001() {
		Logger.start(true,"获取云通信用户签名成功");
		try {
			GetGlobalUserSigBean.setUserId(1);
			GetGlobalUserSigCall.setData(GetGlobalUserSigBean);
			GetGlobalUserSigCall.callService();			
			Logger.verifyEquals("200", GetGlobalUserSigCall.getString("code"), "判断code是否为200");
			String usersig=GetGlobalUserSigCall.getJsonObject().get("data").getAsJsonObject().get("userSig").toString();
			Logger.verifyNotNull(usersig, "验证usersig非空");
			Logger.verifyEquals(usersig.length()>200, true, "usersig长度大于200");
			Logger.debug(usersig);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_GetGlobalUserSig_002() {
		Logger.start(true,"不输入userid失败");
		try {
			GetGlobalUserSigCall.setData(GetGlobalUserSigBean);
			GetGlobalUserSigCall.callService();			
			Logger.verifyEquals("100", GetGlobalUserSigCall.getString("code"), "判断code");
			Logger.verifyIsContains("错误的请求参数", GetGlobalUserSigCall.getString("message"), "判断message");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetGlobalUserSig_003() {
		Logger.start(true,"游客获取云通信用户签名失败");
		try {
			GetGlobalUserSigBean.setUserId(-12345);
			GetGlobalUserSigBean.setDeviceId(TestDataManager.getRandomUUID().toString());
			GetGlobalUserSigCall.setData(GetGlobalUserSigBean);
			GetGlobalUserSigCall.callService();			
			Logger.verifyEquals("100", GetGlobalUserSigCall.getString("code"), "判断code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}